<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>108Wo室内设计数据资源中心 - 批量上传</title>
<link href="{CSS_PATH}reset.css" rel="stylesheet" type="text/css" />
<link href="{CSS_PATH}system.css" rel="stylesheet" type="text/css" />
<link href="{CSS_PATH}table_form.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{JS_PATH}jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="{JS_PATH}admin_common.js"></script>
<link href="{JS_PATH}swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="{JS_PATH}swfupload/swfupload.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_PATH}swfupload/fileprogress.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_PATH}swfupload/handlers.js"></script>
<script type="text/javascript">
//上传后的JS处理
function att_show(serverData,file)
{
	var serverData = serverData.replace(/<div.*?<\/div>/g,'');
	var data = serverData.split(',');
	var id = data[0];
	var src = data[1];
	var ext = data[2];
	var filename = data[3];
	if(id == 0) {
		alert(src)
		return false;
	}
	var img = '<a href="javascript:;" class="on"><div class="icon"></div><img src="'+src+'" width="80" imgid="'+id+'" path="'+src+'" title="'+filename+'"/></a>';
	$('#fsUploadProgress').append('<li><div id="attachment_'+id+'" class="img-wrap"></div></li>');
	$('#attachment_'+id).html(img);
	$('#att-status').append('|'+src);
	$('#att-name').append('|'+filename);
}

//SWF上传对象
var swfu = '';
$(document).ready(function(){
swfu = new SWFUpload({

	flash_url:"{JS_PATH}swfupload/swfupload.swf?"+Math.random(),

	upload_url:"{APP_PATH}index.php?m=content&c=product&a=batchUpload&dosubmit=1",

	file_post_name : "Filedata",

	post_params:{"SWFUPLOADSESSID":"{SYS_TIME}","module":"content","userid":"{$memberinfo[userid]}","username":"{$memberinfo[username]}","bids":"","siteid":"{$siteid}","dosubmit":"1","thumb_width":"0","thumb_height":"0","watermark_enable":"0","filetype_post":"jpg|jpeg|gif|png|bmp","swf_auth_key":"{$swf_auth_key}","isadmin":"0","groupid":"{$memberinfo[groupid]}"},

	file_size_limit:"2048",

	file_types:"*.jpg;*.jpeg;*.gif;*.png;*.bmp",

	file_types_description:"All Files",

	file_upload_limit:"100",

	custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},

 

	button_image_url: "",

	button_width: 75,

	button_height: 28,

	button_placeholder_id: "buttonPlaceHolder",

	button_text_style: "",

	button_text_top_padding: 3,

	button_text_left_padding: 12,

	button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

	button_cursor: SWFUpload.CURSOR.HAND,



	file_dialog_start_handler : fileDialogStart,

	file_queued_handler : fileQueued,

	file_queue_error_handler:fileQueueError,

	file_dialog_complete_handler:fileDialogComplete,

	upload_progress_handler:uploadProgress,

	upload_error_handler:uploadError,

	upload_success_handler:uploadSuccess,

	upload_complete_handler:uploadComplete

	});
})
</script>

<div class="pad-10">
    <div class="col-tab">
        <ul class="tabBut cu-li">
            <li id="tab_swf_1">批量上传</li>
        </ul>
         <div id="div_swf_1" class="content pad-10">
        	<div>
				<div class="addnew" id="addnew">
					<span id="buttonPlaceHolder"></span>

				</div>

				<input type="button" id="btupload" value="开始上传" onClick="uploadSubmit();" />

                <div id="nameTip" class="onShow">最多上传<font color="red"> 100</font> 个附件,单文件最大 <font color="red">2 MB</font></div>

                <div class="bk3"></div>

				

                <div class="lh24">支持 <font style="font-family: Arial, Helvetica, sans-serif">jpg、jpeg、gif、png、bmp</font> 格式。</div>
				<!--<input type="checkbox" id="watermark_enable" value="1"  onclick="change_params()"> 是否添加水印-->
				<br />品牌选择 <select name="brand_1" id="brand_1">
				<option value="">请选择</option>
				{loop $brand_1 $b1}
					<option value='{$b1[id]}'>{$b1[name]}</option>
				{/loop}
				</select>
				<select name="brand_2" id="brand_2">
					<option value="">请选择</option>
	            </select> 
	            <a href="{APP_PATH}index.php?m=brand" target="_top" style="color:orange;">创建品牌</a>
				</div> 	

    		<div class="bk10"></div>

        	<fieldset class="blue pad-10" id="swfupload">

        	<legend>列表</legend>

        	<ul class="attachment-list"  id="fsUploadProgress" style="height:180px; overflow:auto;">    

        	</ul>

    		</fieldset>

    	</div>
    <div id="att-status" class="hidden"></div>
     <div id="att-status-del" class="hidden"></div>
    <div id="att-name" class="hidden"></div>
	<div style="margin:5px 10px 0 0; text-align:right;"><input type="button" value="确认" onclick="top.location.reload();" style="padding:5px 12px;"></div>
<!-- swf -->
</div>
</body>
<script type="text/javascript">
var brands = {$brands_json};
$(function(){
	$("#brand_1").change(function(){
		var bid_1 = this.value;
		var html="";
		if(bid_1=="") {
			$("#brand_2").html("<option value=''>请选择</option>");
			return false;
		}
		for(i in brands) {
			if(brands[i].id == bid_1) {
				for(j in brands[i].child) {
					html += "<option value='"+brands[i].child[j].id+"'>"+brands[i].child[j].name+"</option>";
				}
				if(html=="") {
					$("#brand_2").html("<option value=''>请选择</option>").hide();
				}else {
					html = "<option value=''>请选择</option>"+html;
					$("#brand_2").show().html(html);
				}
			}
		}
	});
});
</script>
<script type="text/javascript">
function uploadSubmit()
{
	if($("#brand_1").size() > 0) {
		if($("#brand_1").val() == "" || ($("#brand_2").val() == "" && $("#brand_2").css('display')!='none')) {
			alert("请选择品牌分类！");
			$("#brand_1").focus();
			return false;
		}
		if($("#brand_2").val()) {
			swfu.addPostParam('bids', $("#brand_1").val()+','+$("#brand_2").val());
		}else {
			swfu.addPostParam('bids', $("#brand_1").val());
		}
		
	}
	
	swfu.startUpload();
}
function imgWrap(obj){
	$(obj).hasClass('on') ? $(obj).removeClass("on") : $(obj).addClass("on");
}
function SwapTab(name,cls_show,cls_hide,cnt,cur) {
    for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_'+name+'_'+i).show();
			 $('#tab_'+name+'_'+i).addClass(cls_show);
			 $('#tab_'+name+'_'+i).removeClass(cls_hide);
		}else{
			 $('#div_'+name+'_'+i).hide();
			 $('#tab_'+name+'_'+i).removeClass(cls_show);
			 $('#tab_'+name+'_'+i).addClass(cls_hide);
		}
	}
}
function addonlinefile(obj) {
	var strs = $(obj).val() ? '|'+ $(obj).val() :'';
	$('#att-status').html(strs);
}

function change_params(){
	if($('#watermark_enable').attr('checked')) {
		swfu.addPostParam('watermark_enable', '1');

	} else {

		swfu.removePostParam('watermark_enable');

	}

}

function set_iframe(id,src){

	$("#"+id).attr("src",src); 

}

function album_cancel(obj,id,source){

	var src = $(obj).children("img").attr("path");

	var filename = $(obj).attr('title');

	if($(obj).hasClass('on')){

		$(obj).removeClass("on");

		var imgstr = $("#att-status").html();

		var length = $("a[class='on']").children("img").length;

		var strs = filenames = '';

		$.get('index.php?m=attachment&c=attachments&a=swfupload_json_del&aid='+id+'&src='+source+'&filename='+filename);

		for(var i=0;i<length;i++){

			strs += '|'+$("a[class='on']").children("img").eq(i).attr('path');

			filenames += '|'+$("a[class='on']").children("img").eq(i).attr('title');

		}

		$('#att-status').html(strs);

		$('#att-status').html(filenames);

	} else {

		var num = $('#att-status').html().split('|').length;

		var file_upload_limit = '1';

		if(num > file_upload_limit) {alert('不能选择超过'+file_upload_limit+'个附件'); return false;}

		$(obj).addClass("on");

		$.get('index.php?m=attachment&c=attachments&a=swfupload_json&aid='+id+'&src='+source+'&filename='+filename);

		$('#att-status').append('|'+src);

		$('#att-name').append('|'+filename);

	}

}

</script>

</html>
